package org.jeecg.modules.nurse_user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.nurse_user.entity.NurseUserIntegral;
import org.jeecg.modules.nurse_user.mapper.NurseUserIntegralMapper;
import org.jeecg.modules.nurse_user.service.INurseUserIntegralService;
import org.springframework.stereotype.Service;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description: 用户积分
 * @Author: jeecg-boot
 * @Date: 2024-06-09
 * @Version: V1.0
 */
@Service
public class NurseUserIntegralServiceImpl extends ServiceImpl<NurseUserIntegralMapper, NurseUserIntegral> implements INurseUserIntegralService {

    @Autowired
    private NurseUserIntegralMapper nurseUserIntegralMapper;

    @Override
    public List<NurseUserIntegral> selectByMainId(String mainId) {
        return nurseUserIntegralMapper.selectByMainId(mainId);
    }

    @Override
    public void deleteByOrderId(String orderId) {
        List<NurseUserIntegral> nurseUserIntegrals = this.list(new QueryWrapper<NurseUserIntegral>().eq("order_id", orderId));
        for (NurseUserIntegral nurseUserIntegral : nurseUserIntegrals) {
            nurseUserIntegral.setStatus("0");
        }
        this.updateBatchById(nurseUserIntegrals);
    }
}
